from django.contrib import admin

from .models import UserProfile, UserFavorite, UserMessage, EmailPro, SecretQuestion, UserSecretAnswer


# Register your models here.


class UserFavoriteAdmin(admin.ModelAdmin):
    list_display = ['user', 'fav_id']
    search_fields = ['user__username', 'fav_id']


class UserMessageAdmin(admin.ModelAdmin):
    list_display = ['user', 'title', 'to_user', 'has_read']
    search_fields = ['user__username', 'title', 'message']
    list_filter = ['has_read']


class EmailProAdmin(admin.ModelAdmin):
    list_display = ['user', 'email', 'code', 'send_type', 'send_time']
    search_fields = ['email', 'code', 'send_type']
    list_filter = ['send_type']


class UserProfileAdmin(admin.ModelAdmin):
    list_display = ['username', 'nick_name', 'mobile', 'email', 'fans',
                    'real_name', 'identity_card', 'is_certificate', 'is_active', 'is_superuser']


@admin.register(SecretQuestion)
class SecretQuestionAdmin(admin.ModelAdmin):
    list_display = ['question']
    search_fields = ['question']
    list_filter = ['question']


@admin.register(UserSecretAnswer)
class UserSecretAnswerAdmin(admin.ModelAdmin):
    list_display = ['user', 'question', 'answer']
    search_fields = ['user', 'question', 'answer']
    list_filter = ['question']


admin.site.register(UserProfile, UserProfileAdmin)
admin.site.register(UserMessage, UserMessageAdmin)
admin.site.register(UserFavorite, UserFavoriteAdmin)
admin.site.register(EmailPro, EmailProAdmin)
